Use AspectGen_Express
Go
SELECT     WEM.EventName
FROM         tblWebEventCustLink AS WEC INNER JOIN
                      tblWebCustomer AS WC ON WEC.CustID = WC.CustID INNER JOIN
                      tblWebEventMaster AS WEM ON WEC.EventID = WEM.EventID INNER JOIN
                      tblWebCompanyMaster AS WCM ON WC.CompanyID = WCM.CompanyID INNER JOIN
                      tblWebSource AS WS ON WC.SourceID = WS.SourceID INNER JOIN
                      tblLocationBase AS LB ON WCM.LocationID = LB.LocationID INNER JOIN
                      tblComboItem AS CB ON ISNULL(WC.CustType, '0') = CB.CIComboTextShort AND CB.CIComboID = 1102
WHERE      (WS.SourceName = N'ASPECT') AND (WEM.LocationID = 1) AND (WCM.LocationID IN
                          (SELECT     LocationID
                            FROM          tblLocationBaseCampaign AS bc
                            WHERE      (LocAccessID = 90)))

GROUP BY WEM.EventName

HAVING      (WS.SourceName = N'ASPECT') AND
(WEM.LocationID = 1) 
			And WCM.LocationID In (select LocationID from tblLocationBaseCampaign bc where bc.LocAccessID = 90)


select DISTINCT cm.CompanyName, cm.CompanyID, lb.CountryName, s.SourceName from tblWebCompanyMaster cm 
                inner join tblWebCustomer c on c.CompanyID = cm.CompanyID
                inner join tblWebSource s on s.SourceID = c.SourceID
                inner join tblLocationBase lb on lb.LocationID = cm.LocationID
                inner join tblComboItem ci on IsNull(c.CustType, '0') = ci.CIComboTextShort and ci.CIComboID = 1102
                where c.IsActive = 1 and lb.LocationID IN (select LocationID from tblLocationBaseCampaign bc 
where bc.LocAccessID = 90) and cm.IsActive = 1 


select DISTINCT cm.CompanyName, cm.CompanyID, lb.CountryName, s.SourceName from tblWebCompanyMaster cm 
                inner join tblWebCustomer c on c.CompanyID = cm.CompanyID
                inner join tblWebSource s on s.SourceID = c.SourceID
                inner join tblLocationBase lb on lb.LocationID = cm.LocationID
                inner join tblComboItem ci on IsNull(c.CustType, '0') = ci.CIComboTextShort and ci.CIComboID = 1102
                where c.IsActive = 1 and lb.LocationID IN (select LocationID from tblLocationBaseCampaign bc 
where bc.LocAccessID = 90) and cm.IsActive = 1  and lb.LocationID = 1 


select top 100 * from tblWebCustomer Where CustID = 13121

select top 100 * from tblDistributorContact

select top 100 * from tblWebEventMaster Where EventID = 131

select top 100 * from tblLocationBase

select top 100 * from tblLocationBaseCampaign order by LocAccessID

select top 100 * from tblWebEventCustLink

select top 100 * from tblWebCompanyMaster Where CompanyID = 16785 Order by CompanyID DESC

select * from tblComboItem WHERE CIComboID = 1102
--Load Event
select distinct ecl.EventID, em.EventName from tblWebEventCustLink ecl
                inner join tblWebEventMaster em on em.EventID = ecl.EventID
                where em.LocationID IN (select LocationID from tblLocationBaseCampaign bc where bc.LocAccessID = 90) 
                order by em.EventName

use aspectgen_express
go
SELECT dc.DisID, ISNULL(dc.Dis_Contact_Person, '') Dis_Contact_Person, ISNULL(dc.Dis_Categorize, '') 
Dis_Categorize, dc.Dis_AccessLevel, ISNULL(dc.Dis_StateShort, '') Dis_StateShort, dc.Dis_UserID, 
lb.CountryCode, ISNULL(lb.StateCode, '') StateCode, dc.LocationID, ISNULL(lb.CountryName, '') CountryName, 
dc.AssignerRoleID, ms.MaxLeadsOwner, ms.IsAssignSelf, dc.Auto_ID, dc.LocAccessID 
FROM tblDistributorContact dc INNER JOIN tblLocationBase lb ON dc.LocationID = lb.LocationID 
INNER JOIN tblMasterSetting ms ON dc.LocationID = ms.LocationID 
WHERE LOWER(dc.Dis_UserID) = @userid AND dc.Dis_Password = @userpass

SELECT     tblWebEventMaster.EventName
FROM         tblWebEventCustLink INNER JOIN
                      tblWebEventMaster ON tblWebEventCustLink.EventID = tblWebEventMaster.EventID INNER JOIN
                      tblWebCustomer ON tblWebEventCustLink.CustID = tblWebCustomer.CustID INNER JOIN
                      tblWebCompanyMaster ON tblWebCustomer.CompanyID = tblWebCompanyMaster.CompanyID INNER JOIN
                      tblLocationBase ON tblWebEventMaster.LocationID = tblLocationBase.LocationID
WHERE     (tblWebEventMaster.LocationID = 1) AND (tblWebEventMaster.LocationID IN
                          (SELECT     tblWebEventMaster.LocationID
                            FROM          tblLocationBaseCampaign
                            WHERE      (LocAccessID = 90)))
Group By tblWebEventMaster.EventName

SELECT     WEM.EventName
FROM         tblWebEventCustLink AS WEC INNER JOIN
                      tblWebEventMaster AS WEM ON WEC.EventID = WEM.EventID INNER JOIN
                      tblWebCustomer AS WC ON WEC.CustID = WC.CustID INNER JOIN
                      tblWebCompanyMaster AS WCM ON WC.CompanyID = WCM.CompanyID INNER JOIN
                      tblLocationBase AS LB ON WEM.LocationID = LB.LocationID INNER JOIN
                      tblWebSource AS WS ON WC.SourceID = WS.SourceID INNER JOIN
                      tblComboItem AS CB ON ISNULL(WC.CustType, '0') = CB.CIComboTextShort AND CB.CIComboID = 1102
WHERE     (WEM.LocationID = 1) AND (WEM.LocationID IN
                          (SELECT     WEM.LocationID
                            FROM          tblLocationBaseCampaign
                            WHERE      (LocAccessID = 90))) AND (WS.SourceName = N'Aspect')
GROUP BY WEM.EventName


SELECT     WEM.EventName
FROM         tblWebEventCustLink AS WEC INNER JOIN
                      tblWebCustomer AS WC ON WEC.CustID = WC.CustID INNER JOIN
                      tblWebEventMaster AS WEM ON WEC.EventID = WEM.EventID INNER JOIN
                      tblWebCompanyMaster AS WCM ON WC.CompanyID = WCM.CompanyID INNER JOIN
                      tblWebSource AS WS ON WC.SourceID = WS.SourceID INNER JOIN
                      tblLocationBase AS LB ON WEM.LocationID = LB.LocationID INNER JOIN
                      tblComboItem AS CB ON ISNULL(WC.CustType, '0') = CB.CIComboTextShort AND CB.CIComboID = 1102
WHERE      (WS.SourceName = N'ASPECT') AND (WEM.LocationID = 1) AND (WEM.LocationID IN
                          (SELECT     LocationID
                            FROM          tblLocationBaseCampaign AS bc
                            WHERE      (LocAccessID = 90)))

GROUP BY WEM.EventName


select DISTINCT cm.LocationID, cm.CompanyName, cm.CompanyID, lb.CountryName, s.SourceName from tblWebCompanyMaster cm 
                inner join tblWebCustomer c on c.CompanyID = cm.CompanyID
                inner join tblWebSource s on s.SourceID = c.SourceID
                inner join tblLocationBase lb on lb.LocationID = cm.LocationID
                inner join tblComboItem ci on IsNull(c.CustType, '0') = ci.CIComboTextShort and ci.CIComboID = 1102
                where c.IsActive = 1  and cm.IsActive = 1  and c.CustID IN (select wc.CustID from tblWebEventCustLink wc where wc.EventID = 131) 

--Customer ID 13121

select * from tblWebCustomer Where CustID = 13121

--update tblWebCustomer Set SourceID  = 1
--Where CustID = 13121 And CompanyID = 16785

select * from tblWebCompanyMaster Where CompanyID = 4476

select top 100 * From tblWebEventMaster 

select * from tblWebEventCustLink Where CustID= 13121